﻿
function unSelectCreate(module, permission) {

    var viewid = module + '-View_List';  // Id of View Checkbox
    var createid = module + '-Create_Edit_Update';
    if (document.getElementById(createid).checked == true) {
        if (document.getElementById(viewid) != null) {
            document.getElementById(viewid).checked = true;
        }
    }
    else { }
}

function unSelectView(module, permission) {

    var createid = module + '-Create_Edit_Update';  //'tab_chk_1_' + id;
    var deleteid = module + '-Delete';              //'tab_chk_2_' + id;
    var viewid = module + '-View_List';

    if (document.getElementById(viewid).checked == false) {     //If View CheckBox is NOT checked  'tab_chk_4_' + id
        if (document.getElementById(createid) != null) {        //If Create CheckBox is exist
            document.getElementById(createid).checked = false;  // Create Checked is NOT checked
        }

        if (document.getElementById(deleteid) != null) {        // If Delete CheckBox is exist
            document.getElementById(deleteid).checked = false;  // Delete Checked is NOT checked
        }
    }
    else { }
}

function unSelectDelete(module, permission) {
    var createid = module + '-Create_Edit_Update';  //'tab_chk_1_' + id;
    var deleteid = module + '-Delete';              //'tab_chk_2_' + id;
    var viewid = module + '-View_List';

    if (document.getElementById(deleteid).checked == false) {   // If Delete CheckBox is NOT checked    $('tab_chk_2_' + id
        // Do nothing
    }
    else {  // If Delete CheckBox is checked
        if (document.getElementById(viewid) != null) {          //If View CheckBox is exits
            document.getElementById(viewid).checked = true;     // View CheckBox is checked
        }
    }
}

function onReset() {
    document.forms[0].action = '<%=ResolveUrl("~/Views/PermissionsAllUsers/SetPermissionsForAllUsers/")%>';
    document.forms[0].method = "get";
    document.forms[0].submit();
}






//..........................JQuery : Below section is not used.............//

function unSelectCreate1(module, permission)
{
    var viewid = module + '-View_List';  // Id of View Checkbox
    if ($("#" + module + '-Create_Edit_Update').is(':checked'))  //if Create is checked
    {
        if ($("#" + viewid).length) // if View CheckBox is exist
        {
            $("#" + viewid).attr('checked', true); // View CheckBox is checked
        }
    }
    else {}
}

function unSelectView1(module, permission) 
{
    var createid = module + '-Create_Edit_Update';  //'tab_chk_1_' + id;
    var deleteid = module + '-Delete';              //'tab_chk_2_' + id;
    if (!$("#" + module + '-View_List').is(':checked'))      //If View CheckBox is NOT checked  'tab_chk_4_' + id
    {
        if ($("#" + createid).length) // If Create CheckBox is exist
        {
            $("#" + createid).attr('checked', false);  // Create Checked is NOT checked
        }

        if ($("#" + deleteid).length) // If Delete CheckBox is exist
        {
            $("#" + deleteid).attr('checked', false);  // Delete Checked is NOT checked
        }
        
    }
    else { }
}

function unSelectDelete1(module, permission) {
    if (!$("#" + module + '-Delete').is(':checked'))   // If Delete CheckBox is NOT checked    $('tab_chk_2_' + id
    {           //nothing 
    }
    else      // If Delete CheckBox is checked
    {
        var viewid = module + '-View_List';              //'tab_chk_4_' + id;

        if ($("#" + viewid).length)  //If View CheckBox is exits
        {
            $("#" + viewid).attr('checked', true); // View CheckBox is checked
        }
    }
}

function unSelectCreateRole(module, permission) {
    var viewid = module + '-View_List';  // Id of View Checkbox
    if ($("#" + module + '-Create_Edit_Update').is(':checked'))  //if Create is checked
    {
        if ($("#" + viewid).length) // if View CheckBox is exist
        {
            $("#" + viewid).attr('checked', true); // View CheckBox is checked
        }
    }
    else { }
}

function unSelectViewRole(module, permission) {
    var createid = module + '-Create_Edit_Update';  //'tab_chk_1_' + id;
    var deleteid = module + '-Delete';              //'tab_chk_2_' + id;
    if (!$("#" + module + '-View_List').is(':checked'))      //If View CheckBox is NOT checked  'tab_chk_4_' + id
    {
        if ($("#" + createid).length) // If Create CheckBox is exist
        {
            $("#" + createid).attr('checked', false);  // Create Checked is NOT checked
        }

        if ($("#" + deleteid).length) // If Delete CheckBox is exist
        {
            $("#" + deleteid).attr('checked', false);  // Delete Checked is NOT checked
        }

    }
    else { }
}

function unSelectDeleteRole(module, permission) {
    if (!$("#" + module + '-Delete').is(':checked'))   // If Delete CheckBox is NOT checked    $('tab_chk_2_' + id
    {           //nothing 
    }
    else      // If Delete CheckBox is checked
    {
        var viewid = module + '-View_List';              //'tab_chk_4_' + id;

        if ($("#" + viewid).length)  //If View CheckBox is exits
        {
            $("#" + viewid).attr('checked', true); // View CheckBox is checked
        }
    }
}

